package simbot.example;

import lombok.extern.slf4j.Slf4j;
import love.forte.common.configuration.Configuration;
import love.forte.simbot.api.sender.BotSender;
import love.forte.simbot.bot.Bot;
import love.forte.simbot.core.SimbotContext;
import love.forte.simbot.core.SimbotProcess;
import love.forte.simbot.spring.autoconfigure.EnableSimbot;
import org.jetbrains.annotations.NotNull;
import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.annotation.MapperScans;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.time.LocalDateTime;

/**
 * 启动类。
 * 其中，{@link SpringBootApplication} 为springboot的启动注解，
 * {@link EnableSimbot} 为simbot在springboot-starter下的启动注解。
 *
 * @author ForteScarlet
 */
@Slf4j
@EnableSimbot
@EnableCaching
@EnableScheduling
@MapperScan("simbot.example.data.mapper")
@SpringBootApplication
public class SimbotExampleApplication implements SimbotProcess {

    public static void main(String[] args) {
        SpringApplication.run(SimbotExampleApplication.class, args);
    }

    @Override
    public void post(@NotNull SimbotContext context) {
        Bot bot = context.getBotManager().getDefaultBot();
        BotSender sender = bot.getSender();
        sender.SENDER.sendPrivateMsg(1053557904, "镜华酱出击!" + LocalDateTime.now());
    }

    @Override
    public void pre(@NotNull Configuration config) {
        log.debug("镜华酱正在启动....");
    }

}
